package io.codescience.aianaly.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 映射上传的文件
        registry.addResourceHandler("/uploads/**")
                .addResourceLocations("file:./uploads/");

        // 映射静态资源
        registry.addResourceHandler("/static/**")
                .addResourceLocations("classpath:/static/");

        // 映射根路径到静态资源
        registry.addResourceHandler("/images/**")
                .addResourceLocations("classpath:/static/images/");
    }
}